import ij.ImagePlus;
import ij.measure.Measurements;
import ij.measure.ResultsTable;
import ij.plugin.filter.Analyzer;
import ij.process.ImageStatistics;

public class center_mass {
	ImageStatistics stats;
	double x1, y1, x2, y2;
	Analyzer ana;
	public static int xMass,yMass;

	public void find_center_of_mass(ImagePlus mask_Channel1, ImagePlus mask_Channel2) {

		ResultsTable rt = new ResultsTable();
		ana = new Analyzer(mask_Channel1, Measurements.CENTER_OF_MASS, rt);
		ana.run(mask_Channel1.getProcessor());

		x1 = rt.getValue(rt.X_CENTER_OF_MASS, 0);
		y1 = rt.getValue(rt.Y_CENTER_OF_MASS, 0);

		ResultsTable rt1 = new ResultsTable();
		ana = new Analyzer(mask_Channel2, Measurements.CENTER_OF_MASS, rt1);
		ana.run(mask_Channel2.getProcessor());
		
		x2 = rt.getValue(rt1.X_CENTER_OF_MASS, 0);
		y2 = rt.getValue(rt1.Y_CENTER_OF_MASS, 0);

		// Avg of center of Mask for Actin and Myosin
		 xMass = (int) (x1 + x2) / 2;
		 yMass = (int) (y1 + y2) / 2;
	}

}